package com.ruoyi.projects.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.SlIntegralDetails;
import com.ruoyi.projects.service.ISlIntegralDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员积分明细Controller
 * 
 * @author yangz
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/projects/SlIntegralDetails")
public class SlIntegralDetailsController extends BaseController
{
    @Autowired
    private ISlIntegralDetailsService slIntegralDetailsService;

    /**
     * 查询会员积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlIntegralDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlIntegralDetails slIntegralDetails)
    {
        startPage();
        List<SlIntegralDetails> list = slIntegralDetailsService.selectSlIntegralDetailsList(slIntegralDetails);
        return getDataTable(list);
    }

    /**
     * 导出会员积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlIntegralDetails:export')")
    @Log(title = "会员积分明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlIntegralDetails slIntegralDetails)
    {
        List<SlIntegralDetails> list = slIntegralDetailsService.selectSlIntegralDetailsList(slIntegralDetails);
        ExcelUtil<SlIntegralDetails> util = new ExcelUtil<SlIntegralDetails>(SlIntegralDetails.class);
        util.exportExcel(response, list, "会员积分明细数据");
    }

    /**
     * 获取会员积分明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:SlIntegralDetails:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(slIntegralDetailsService.selectSlIntegralDetailsById(id));
    }

    /**
     * 新增会员积分明细
     */
    @PreAuthorize("@ss.hasPermi('projects:SlIntegralDetails:add')")
    @Log(title = "会员积分明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlIntegralDetails slIntegralDetails)
    {
        return toAjax(slIntegralDetailsService.insertSlIntegralDetails(slIntegralDetails));
    }

    /**
     * 修改会员积分明细
     */
    @PreAuthorize("@ss.hasPermi('projects:SlIntegralDetails:edit')")
    @Log(title = "会员积分明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlIntegralDetails slIntegralDetails)
    {
        return toAjax(slIntegralDetailsService.updateSlIntegralDetails(slIntegralDetails));
    }

    /**
     * 删除会员积分明细
     */
    @PreAuthorize("@ss.hasPermi('projects:SlIntegralDetails:remove')")
    @Log(title = "会员积分明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slIntegralDetailsService.deleteSlIntegralDetailsByIds(ids));
    }
}
